package com.usian.comment.controller;

import com.usian.apis.comment.ApCommentControllerApi;
import com.usian.comment.service.ApCommentService;
import com.usian.model.comment.dtos.CommentDto;
import com.usian.model.comment.dtos.CommentLikeDto;
import com.usian.model.comment.dtos.CommentSaveDto;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
public class ApCommentController implements ApCommentControllerApi {
    @Autowired
    private ApCommentService apCommentService;

    @Override
    @PostMapping("/save")/*保存评论*/
    public ResponseResult saveApComment(@RequestBody CommentSaveDto dto) {
        return apCommentService.saveComment(dto);
    }

    @Override
    @PostMapping("/like")/*点赞某一个评论*/
    public ResponseResult like(@RequestBody CommentLikeDto dto) {
        return apCommentService.like(dto);
    }

    @Override
    @PostMapping("/load")/*根据文章id查询评论列表*/
    public ResponseResult findByArticleId(@RequestBody CommentDto dto) {
        return apCommentService.findByArticleId(dto);
    }
}
